<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <style>
    
  </style>
</head>
<body>
  <textarea id="txt1"></textarea>
  <input type="button" id="btn" value="发送">
  <textarea id="txt2"></textarea>
</body>
<script>
  var txt1 = document.getElementById("txt1");
  var txt2 = document.getElementById("txt2");
  var btn = document.getElementById("btn");

  var arr = ["你好", "开心", "abc", "hello", "123"];

  btn.onclick = function(){
    // 获取字符
    var str = txt1.value;
    // 替换
    // 先遍历出每个敏感词
    for(var i=0;i<arr.length;i++){
      // 假设整个字符全都触犯了敏感词，每个敏感词替换字符长度次
      for(var j=0;j<str.length;j++){
        str = str.replace(arr[i], "***");
      }
    }
    // 设置到结果框
    txt2.value = str;
  }

  
  // replaceAll()

</script>
</html>